package com.example.demo.controller;

import java.util.Map;

import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class DemoController {

    @GetMapping("/user")
    public UserInfo getUserInfo(@RequestParam(required = false) String userId) {
        // 模拟返回用户信息
        return new UserInfo("张三", 30, "gitcode-test-zsy-d");
    }

    @PostMapping("/feedback")
    public ResponseResult submitFeedback(@RequestBody FeedbackRequest feedback) {
        System.out.println("feedback: " + feedback);
        System.out.println("service_name: " + feedback.getService_name());
        System.out.println("service_type: " + feedback.getService_type());
        System.out.println("environment: " + feedback.getEnvironment());
        System.out.println("deploy: " + feedback.getDeploy());
        // 模拟处理用户反馈
        return new ResponseResult(200, "反馈提交成功！");
    }

    @PostMapping("/contact")
    public ResponseResult submitContact(@RequestBody Map<String, Object> contact) {
        System.out.println("contact: " + contact);
        System.out.println("service_name: " + contact.get("service_name"));
        System.out.println("service_type: " + contact.get("service_type"));
        System.out.println("environment: " + contact.get("environment"));
        System.out.println("deploy: " + contact.get("deploy"));
        // 模拟处理用户反馈
        return new ResponseResult(200, "反馈提交成功！");
    }
}

class UserInfo {
    private String name;
    private int age;
    private String address;

    public UserInfo(String name, int age, String address) {
        this.name = name;
        this.age = age;
        this.address = address;
    }

    // Getters and Setters
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
    public int getAge() { return age; }
    public void setAge(int age) { this.age = age; }
    public String getAddress() { return address; }
    public void setAddress(String address) { this.address = address; }
}

class FeedbackRequest {
    private String content;
    private String userEmail;
    private String service_name;
    private String service_type;
    private String environment;
    private Boolean deploy;



    // Getters and Setters
    public String getContent() { return content; }
    public void setContent(String content) { this.content = content; }
    public String getUserEmail() { return userEmail; }
    public void setUserEmail(String userEmail) { this.userEmail = userEmail; }

    public String getService_name() { return service_name; }
    public void setService_name(String service_name) { this.service_name = service_name; }
    public String getService_type() { return service_type; }
    public void setService_type(String service_type) { this.service_type = service_type; }
    public String getEnvironment() { return environment; }
    public void setEnvironment(String environment) { this.environment = environment; }
    public Boolean getDeploy() { return deploy; }
    public void setDeploy(Boolean deploy) { this.deploy = deploy; }
    
}

class ResponseResult {
    private int code;
    private String message;

    public ResponseResult(int code, String message) {
        this.code = code;
        this.message = message;
    }

    // Getters and Setters
    public int getCode() { return code; }
    public void setCode(int code) { this.code = code; }
    public String getMessage() { return message; }
    public void setMessage(String message) { this.message = message; }
} 